package com.landeb.shop.huo.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.landeb.shop.R;

/**
 * Created by qiling on 2017/7/26.
 */

public class MyBadgeItem extends LinearLayout {
    private Context mContext;

    private ImageView mBadge, mImg;
    private TextView mPrice, mTilte;

    public MyBadgeItem(Context context) {
        super(context);
        mContext = context;
        initView();
    }

    public MyBadgeItem(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        mContext = context;
        initView();

    }

    public MyBadgeItem(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        mContext = context;
        initView();

    }


    private void initView() {

        View view = LayoutInflater.from(mContext).inflate(R.layout.badge_item_layout, this,true);

        mBadge = (ImageView) view.findViewById(R.id.badge_item);
        mImg = (ImageView) view.findViewById(R.id.iv_item);
        mPrice = (TextView) view.findViewById(R.id.tv_price_item);
        mTilte = (TextView) view.findViewById(R.id.tv_title_item);

//        addView(view);
    }

    public void setmBadge(String url) {

        if (!TextUtils.isEmpty(url)) {
            Glide.with(mContext).load(url).into(mBadge);
        }
    }

    public void setmImg(String url) {

        if (!TextUtils.isEmpty(url)) {
            Glide.with(mContext).load(url).into(mImg);
        }
    }

    public void setmPrice(String price) {

        if (!TextUtils.isEmpty(price)) {
            mPrice.setText(price);
        }
    }

    public void setmTilte(String title) {
        if (!TextUtils.isEmpty(title)) {
            mTilte.setText(title);
        }
    }
}
